'''
this is the base site
'''

def start(args):
    import os
    
    path, file = os.path.split(__file__)
    
    templates = os.path.join(path, 'templates')
    
    loader = args['loader']
    rpc = loader.get_component('rpc')
    router = loader.get_component('server.WSGI_Server').get_router()
    
    wrap = loader.get_component('utils.wrap')
    add_path = loader.get_component('utils.add_path')
    render_template = loader.get_component('utils.render_template')
    
    manager = args['bundle_manager']
    
    add_path(templates)
    
    @rpc.function
    def get_homepages():
        return manager.homepages
    
    @router.route('/')
    def main(header, request, response_headers):
        return render_template('index.html', {'homepages' : manager.homepages})
    
def stop(args):
    router = loader.get_component('wsgi_server.WSGI_Server').get_router()
    router.delete_route('/')
